//MODIFIED BY Cio
//Original idea by @Cio
//Based on the original ideas and open source.
//Special thanks to 8Zamania, suggestion for ATR adjustments in 1D timeframe, and Design. 2023
//User SuperTrend: KivancOzbilgic

//@version=5
indicator("Supertrend Algorithm", overlay = true
  , max_labels_count = 500
  , max_lines_count = 500
  , max_boxes_count = 500
  , max_bars_back = 500
  , precision=4
  , linktoseries=true
  , max_bars_back=1000
  , max_lines_count=500)

// Module - TOOLS AND UTILITIES
//-----------------------------------------
//*********************************************************
//*                     Module                            *
//*                    TOOLS                               *
//*********************************************************
// Calculations
//--------
// Group: Module Options
group1 = "Module - TOOLS"
// Visual separation
plot(na)

showADMINVST_Ema = input.bool(false, "Show Ema ADMINVST 10", inline = "EMA ADMINVST 10", group=group1,tooltip="Default in the Investing Bull guide, 10-step type")
colorEmaADMINVST = input.color(color.lime, "Color Ema ADMINVST 10", inline = "EMA ADMINVST 10", group=group1)
emaADMINVST = ta.ema(close, 10)
plot(showADMINVST_Ema ? emaADMINVST : na, color = colorEmaADMINVST, linewidth = 2, style = plot.style_stepline)

showADMINVST2_Sma = input.bool(false, "Show Sma Type 1", inline = "SEMA Type 1", group=group1)
colorEmaADMINVST2 = input.color(color.aqua, "Color Sma Type 1", inline ="SEMA Type 1", group=group1)
lenADMINVST2 = input(title='length', defval=200, inline = "SEMA Type 1", group=group1 ,tooltip="Default 200 for trend filtering")
emaADMINVST2 = ta.sma(close, lenADMINVST2)
plot(showADMINVST2_Sma ? emaADMINVST2 : na, color = colorEmaADMINVST2, linewidth = 2)

showADMINVST3_Sma = input.bool(false, "Show Sma Type 2", inline = "SEMA Type 2", group=group1)
colorEmaADMINVST3 = input.color(color.yellow, "Color Sma Type 2", inline ="SEMA Type 2", group=group1)
lenADMINVST3 = input(title='length', defval=50, inline = "SEMA Type 2", group=group1,tooltip="Default 50 for trend filtering")
emaADMINVST3 = ta.sma(close, lenADMINVST3)
plot(showADMINVST3_Sma ? emaADMINVST3 : na, color = colorEmaADMINVST3, linewidth = 2)

showZLSMA = input.bool(false, "Show ZLSMA", inline = "ZLSMA CoM_gUnNeR",tooltip="Used for Short / Long channels +- 5%")
length = 32
offsetZLSMA = 0
srcZLSMA = close
lsma = ta.linreg(srcZLSMA, length, offsetZLSMA)
lsma2 = ta.linreg(lsma, length, offsetZLSMA)
eq = lsma - lsma2
zlsma = lsma + eq
plot(showZLSMA ? zlsma : na, color=color.new(color.gray, 0), linewidth=3)
plot(showZLSMA and ta.cross(zlsma, emaADMINVST) ? zlsma : na,color = color.lime, style = plot.style_cross, linewidth = 4)

showlength_hullmas = input.bool(false, "Show Hullma`s and Crosses", inline = "Hullma`s 50/100",tooltip="Used for Short / Long channels +- 5%")
//HULL AVERAGES 50
hullma = ta.hma(close, 50)
//HULL AVERAGES 150
hullma2 = ta.hma(close, 100)

plot(showlength_hullmas ? hullma : na, color=color.rgb(33, 149, 243, 60), linewidth = 2)
plot(showlength_hullmas ? hullma2 : na, color=color.rgb(243, 198, 0, 60),linewidth = 2)
plot(showlength_hullmas and ta.cross(hullma, hullma2) ? hullma : na,color = color.rgb(239, 176, 17), style = plot.style_cross, linewidth = 4)

//EMAs 34/87

showEMAs34_87 = input.bool(false, "Show EMAs and Crosses 34/87 ", inline = "EMAs34/87",tooltip="Suggested for short-term trend filtering Narvaez's long and short crosses")
showEMAs34_200 = input.bool(false, "Show EMAs and Crosses 34/200 ", inline = "EMAs34/200",tooltip="Suggested for long-term trend filtering Narvaez's long and short crosses")

ema34cross = ta.ema(close, 34)
ema87cross = ta.sma(close, 87)
ema200cross = ta.sma(close, 200)

plot(showEMAs34_87 ? ema34cross : na, color = color.rgb(248, 221, 138, 60), linewidth = 2)
plot(showEMAs34_87 ? ema87cross : na, color = color.rgb(5, 242, 206, 60),linewidth = 2)
plot(showEMAs34_87 and ta.cross(ema34cross, ema87cross) ? ema34cross : na,color = color.lime, style = plot.style_cross, linewidth = 4)

plot(showEMAs34_200 ? ema34cross : na, color = color.rgb(242, 182, 3, 60), linewidth = 2)
plot(showEMAs34_200 ? ema200cross : na, color = color.rgb(5, 87, 74, 60),linewidth = 2)
plot(showEMAs34_200 and ta.cross(ema34cross, ema200cross) ? ema34cross : na,color = color.lime, style = plot.style_cross, linewidth = 4)

//EMAs 13/30

showEMAs13_30 = input.bool(false, "Show EMAs and Crosses 13/30", inline = "EMAs13/30",tooltip="Suggested for trend change CoMgUnNeR's long and short crosses")
ema13cross = ta.ema(close, 13)
ema30cross = ta.sma(close, 30)
plot(showEMAs13_30 ? ema13cross : na, color = color.rgb(255, 82, 82, 60), linewidth = 2)
plot(showEMAs13_30 ? ema30cross : na, color = color.rgb(76, 175, 79, 60),linewidth = 2)
plot(showEMAs13_30 and ta.cross(ema13cross, ema30cross) ? ema13cross : na,color = color.rgb(239, 176, 17), style = plot.style_cross, linewidth = 4)

//EMAs10/120
showEMAs10_120 = input.bool(false, "Show EMAs and Crosses 10/120", inline = "EMAs10/120" ,tooltip="Suggested as trend change by bitcoiners.la")
showEMAs4_120 = input.bool(false, "Show EMAs and Crosses 4/120", inline = "EMAs4/120" ,tooltip="Suggested for long/short entry by bitcoiners.la")

ema120cross = ta.ema(close, 120)
ema10cross = ta.ema(close, 10)
ema4cross = ta.ema(close, 4)
//CROSSES
goldencrossLong120 = ta.crossover(ema10cross,ema120cross)
goldencrossShort120 = ta.crossunder(ema10cross,ema120cross)

plot(showEMAs10_120 ? ema10cross : na, color = color.rgb(255, 82, 82, 60), linewidth = 2)
plot(showEMAs10_120 ? ema120cross : na, color = color.rgb(76, 175, 79, 60),linewidth = 2)
plot(showEMAs10_120 and ta.cross(ema10cross, ema120cross) ? ema10cross : na,color = color.rgb(225, 236, 2), style = plot.style_cross, linewidth = 4)

plot(showEMAs4_120 ? ema4cross : na, color = color.rgb(255, 82, 82, 60), linewidth = 2)
plot(showEMAs4_120 ? ema120cross : na, color = color.rgb(76, 175, 79, 60),linewidth = 2)
plot(showEMAs4_120 and ta.cross(ema4cross, ema120cross) ? ema4cross : na,color = color.rgb(225, 236, 2), style = plot.style_cross, linewidth = 4)

//EMAs50/200
showEMAs50_200 = input.bool(false, "Show EMAs and Crosses 50/200", inline = "EMAs50/200",tooltip="Suggested for trend change SWING CoMgUnNeR's long and short crosses")
emaSource50cross = ta.ema(close, 50)
smaSource200cross = ta.sma(close, 200)

plot(showEMAs50_200 ? emaSource50cross : na, color = color.rgb(249, 91, 0, 60), linewidth = 2)
plot(showEMAs50_200 ? smaSource200cross : na, color = color.rgb(236, 248, 2, 60),linewidth = 2)
plot(showEMAs50_200 and ta.cross(emaSource50cross, smaSource200cross) ? emaSource50cross : na, color = color.white, style = plot.style_cross, linewidth = 4)

//CLASSIC EMAs

showEMAsClassic = input.bool(false, "Show EMAs and Crosses 20/50/100/200", inline = "Classic EMAs")
emaClassic20 = ta.ema(close, 20)
emaClassic50 = ta.ema(close, 50)
emaClassic100 = ta.ema(close, 100)
emaClassic200 = ta.ema(close, 200)

plot(showEMAsClassic ? emaClassic20 : na, color = color.rgb(255, 82, 82, 60), linewidth = 2)
plot(showEMAsClassic ? emaClassic50 : na, color = color.rgb(255, 153, 0, 60),linewidth = 2)
plot(showEMAsClassic ? emaClassic100 : na, color = color.rgb(0, 187, 212, 60),linewidth = 2)
plot(showEMAsClassic ? emaClassic200 : na, color = color.rgb(33, 149, 243, 60),linewidth = 2)

plot(showEMAsClassic and ta.cross(emaClassic20, emaClassic50) ? ema13cross : na,color = color.rgb(246, 246, 246), style = plot.style_cross, linewidth = 4)
plot(showEMAsClassic and ta.cross(emaClassic20, emaClassic100) ? ema13cross : na,color = color.rgb(249, 190, 190), style = plot.style_cross, linewidth = 4)
plot(showEMAsClassic and ta.cross(emaClassic20, emaClassic200) ? ema13cross : na,color = color.rgb(249, 190, 190), style = plot.style_cross, linewidth = 4)

// Module - SUPERTREND
//-----------------------------------------
//*********************************************************
//*                     Module                            *
//*                    SUPERTREND                         *
//*********************************************************
// Calculations

// Group 2: Module Options
group2 = "Module - SUPERTREND"
// Visual separation
plot(na)
//, group=group2

//, tooltip='The number of left and right bars checked when searching for a swing point. Higher value = fewer swing points plotted and lower value = more swing points plotted.' ,

showST = input.bool(false, "Show SUPER-TREND", inline="SUPER TREND", group=group2, tooltip="Enable/Disable Supertrend")
showBuySell = input(title='Show Buy/Sell Labels?', defval=true, group=group2, tooltip="Enable Buy/Sell labels in Supertrend")

// DEFAULT: 10 ATR and 5 ATR M. 100 and 5 / 8Zamania: 1, 2
Periods = input(title='ATR Period', defval=10, group=group2, tooltip="Default: 10 / Narvaez: 100 / 8Zamania: 1 TEMP 1D")
src = input(close, title='Source', group=group2)
Multiplier = input.float(title='ATR Multiplier', step=0.1, defval=3.0, group=group2, tooltip="Default: 3 / Narvaez: 5 / 8Zamania: 2 TEMP 1D")
changeATR = input(title='Change ATR Calculation Method?', defval=true, group=group2)
showSignals = input(title='Show Buy/Sell Signals?', defval=true, group=group2)
highlighting = input(title='Highlighter On/Off?', defval=true, group=group2)
atr2 = ta.sma(ta.tr, Periods)
atr = changeATR ? ta.atr(Periods) : atr2
up = src - Multiplier * atr
up1 = nz(up[1], up)
up := close[1] > up1 ? math.max(up, up1) : up
dn = src + Multiplier * atr
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? math.min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend

upPlot = plot(showST and trend == 1 ? up : na, title='Up Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0))
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title='UpTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(#07680a, 0))
plotshape(buySignal and showBuySell ? up : na, title='Buy', text='Buy', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(#097417, 43), textcolor=color.new(color.white, 0))
dnPlot = plot(showST and trend == -1 ? dn : na, title='Down Trend', style=plot.style_linebr, linewidth=2, color=color.new(color.red, 0))

sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title='DownTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(#920808, 0))
plotshape(sellSignal and showBuySell ? dn : na, title='Sell', text='Sell', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(#970e0e, 35), textcolor=color.new(color.white, 0))
mPlot = plot(ohlc4, title='', style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? trend == 1 ? color.green : color.white : color.white
shortFillColor = highlighting ? trend == -1 ? color.red : color.white : color.white

fill(mPlot, upPlot, title='UpTrend Highlighter', color=showST ? longFillColor : na, transp=90)
fill(mPlot, dnPlot, title='DownTrend Highlighter', color=showST ? shortFillColor : na, transp=90)

changeCond = trend != trend[1]

// Module - SMARTCONCEPT
//-----------------------------------------
//*********************************************************
//*                     Module                            *
//*                  SMARTCONCEPT                         *
//*********************************************************
// Calculations

// Group: Module Options
group3 = "Module - SMARTCONCEPT"
// Visual separation
plot(na)
//, group=group3

// Constants
color CLEAR = color.rgb(0,0,0,100)

// Inputs
swingSize = input.int(20, 'Swing Length', tooltip='The number of left and right bars checked when searching for a swing point. Higher value = less swing points plotted and lower value = more swing points plotted.', group=group3)
bosConfType = input.string('Candle Close', 'BOS Confirmation', ['Candle Close', 'Wicks'], tooltip='Choose whether candle close/wick above the previous swing point counts as a BOS.')
choch = input.bool(true, 'Show CHoCH', tooltip='Renames the first counter-trend BOS to CHoCH')
showSwing = input.bool(true, 'Show Swing Points', tooltip='Show or hide HH, LH, HL, LL')

showHalf = input.bool(true, 'Show 0.5 Retracement Level', group='0.5 Retracement Level', tooltip='Show a possible 0.5 retracement level between the swing highs and lows of an expansion move.')
halfColor = input.color(color.rgb(41, 39, 176), 'Color', group='0.5 Retracement Level')
halfStyle = input.string('Solid', 'Line Style', ['Solid', 'Dashed', 'Dotted'], group='0.5 Retracement Level')
halfWidth = input.int(1, 'Width', minval=1, group='0.5 Retracement Level')

bosColor = input.color(color.rgb(112, 114, 119), 'Color', group='BOS Settings')
bosStyle = input.string('Dashed', 'Line Style', ['Solid', 'Dashed', 'Dotted'], group='BOS Settings')
bosWidth = input.int(1, 'Width', minval=1, group='BOS Settings')

// Functions
lineStyle(x) =>
    switch x
        'Solid' => line.style_solid
        'Dashed' => line.style_dashed
        'Dotted' => line.style_dotted

// Calculations

// Finding high and low pivots
pivHi = ta.pivothigh(high, swingSize, swingSize)
pivLo = ta.pivotlow(low, swingSize, swingSize)

// Tracking the previous swing levels to determine hh lh hl ll
var float prevHigh = na
var float prevLow = na
var int prevHighIndex = na
var int prevLowIndex = na

// Tracking whether previous levels have been breached
var bool highActive = false
var bool lowActive = false

bool hh = false
bool lh = false
bool hl = false
bool ll = false

// Variable to track the previous swing type, used later on to draw 0.5 Retracement Levels (HH = 2, LH = 1, HL = -1, LL = -2)
var int prevSwing = 0

if not na(pivHi)
    if pivHi >= prevHigh
        hh := true
        prevSwing := 2
    else
        lh := true
        prevSwing := 1
    prevHigh := pivHi
    highActive := true
    prevHighIndex := bar_index - swingSize

if not na(pivLo)
    if pivLo >= prevLow
        hl := true
        prevSwing := -1
    else
        ll := true
        prevSwing := -2
    prevLow := pivLo
    lowActive := true
    prevLowIndex := bar_index - swingSize

// Generating the breakout signals
bool highBroken = false
bool lowBroken = false

// Tracking prev breakout
var int prevBreakoutDir = 0

float highSrc = bosConfType == 'Candle Close' ? close : high
float lowSrc = bosConfType == 'Candle Close' ? close : low

if highSrc > prevHigh and highActive
    highBroken := true
    highActive := false
if lowSrc < prevLow and lowActive
    lowBroken := true
    lowActive := false

// Visual Output

// Swing level labels
if hh and showSwing
    label.new(bar_index - swingSize, pivHi, 'HH', color=CLEAR, style=label.style_label_down, textcolor=chart.fg_color)
    // Detecting if it is an HH after an HL
    if prevSwing[1] == -1 and showHalf
        line.new(prevLowIndex, (prevLow + pivHi) / 2, bar_index - swingSize, (prevLow + pivHi) / 2, color=halfColor, style=lineStyle(halfStyle), width=halfWidth)
if lh and showSwing
    label.new(bar_index - swingSize, pivHi, 'LH', color=CLEAR, style=label.style_label_down, textcolor=chart.fg_color)
if hl and showSwing
    label.new(bar_index - swingSize, pivLo, 'HL', color=CLEAR, style=label.style_label_up, textcolor=chart.fg_color)
if ll and showSwing
    label.new(bar_index - swingSize, pivLo, 'LL', color=CLEAR, style=label.style_label_up, textcolor=chart.fg_color)
    // Detecting if it is an LL after an LH
    if prevSwing[1] == 1 and showHalf
        line.new(prevHighIndex, (prevHigh + pivLo) / 2, bar_index - swingSize, (prevHigh + pivLo) / 2, color=halfColor, style=lineStyle(halfStyle), width=halfWidth)

// Generating the BOS Lines
if highBroken
    line.new(prevHighIndex, prevHigh, bar_index, prevHigh, color=bosColor, style=lineStyle(bosStyle), width=bosWidth)
    label.new(math.floor(bar_index - (bar_index - prevHighIndex) / 2), prevHigh, prevBreakoutDir == -1 and choch ? 'CHoCH' : 'BOS', color=CLEAR, textcolor=bosColor, size=size.tiny)
    prevBreakoutDir := 1
if lowBroken
    line.new(prevLowIndex, prevLow, bar_index, prevLow, color=bosColor, style=lineStyle(bosStyle), width=bosWidth)
    label.new(math.floor(bar_index - (bar_index - prevLowIndex) / 2), prevLow, prevBreakoutDir == 1 and choch ? 'CHoCH' : 'BOS', color=CLEAR, textcolor=bosColor, style=label.style_label_up, size=size.tiny)
    prevBreakoutDir := -1

// Module - VOLUME PROFILE
//-----------------------------------------
//*********************************************************
//*                     Module                            *
//*                  VOLUME PROFILE                        *
//*********************************************************
// Calculations

// Group 3: Module Options
group4 = "Module - VOLUME PROFILE"
// Visual separation
plot(na)
//, group=group4

//////////////////////////////////////////////////////////////////////////////////////////////////
//// INPUTS
///////////////////////////////////////////////////////////////////////////////////////////////////
vp_lookback = input.int(defval=200, title='Volume Lookback Depth [10-1000]', minval=10, maxval=1000, group=group4)

vp_max_bars = input.int(defval=500, title='Number of Bars [10-500]', minval=10, maxval=500)

vp_bar_mult = input.int(defval=50, title='Bar Length Multiplier [10-100]', minval=10, maxval=100)

vp_bar_offset = input.int(defval=30, title='Bar Horizontal Offset [0-100]', minval=0, maxval=100)

vp_bar_width = input.int(defval=2, title='Bar Width [1-20]', minval=1, maxval=20)

// As suggested by @NXT2017 to @kv4coins
vp_delta_type = input.string(defval='BOTH', title='VP Delta Type // Volume Profile Delta Variable.', options=['BOTH', 'Bullish', 'Bearish'])

vp_poc_show = input(defval=false, title='VP Extend POC Line // Extend the Point of Control Line of the Volume Profile.')

vp_bar_color = input(defval=color.new(color.aqua, 75), title='VP Bar Color // Color of the Volume Profile Bar.')

vp_poc_color = input(defval=color.new(color.aqua, 0), title='VP POC Color // Color of the Volume Profile Point of Control')

///////////////////////////////////////////////////////////////////////////////////////////////////
//// VARIABLES
///////////////////////////////////////////////////////////////////////////////////////////////////
float vp_Vmax = 0.0
int vp_VmaxId = 0
int vp_N_BARS = vp_max_bars

var int vp_first = time

vp_a_P = array.new_float(vp_N_BARS + 1, 0.0)
vp_a_V = array.new_float(vp_N_BARS, 0.0)
vp_a_D = array.new_float(vp_N_BARS, 0.0)
vp_a_W = array.new_int(vp_N_BARS, 0)

///////////////////////////////////////////////////////////////////////////////////////////////////
//// CALCULATIONS
///////////////////////////////////////////////////////////////////////////////////////////////////
float vp_HH = ta.highest(high, vp_lookback)
float vp_LL = ta.lowest(low, vp_lookback)

if barstate.islast
    float vp_HL = (vp_HH - vp_LL) / vp_N_BARS
    for j = 1 to vp_N_BARS + 1 by 1
        array.set(vp_a_P, j - 1, vp_LL + vp_HL * j)
    for i = 0 to vp_lookback - 1 by 1
        int Dc = 0
        array.fill(vp_a_D, 0.0)
        for j = 0 to vp_N_BARS - 1 by 1
            float Pj = array.get(vp_a_P, j)
            if low[i] < Pj and high[i] > Pj and (vp_delta_type == 'Bullish' ? close[i] >= open[i] : vp_delta_type == 'Bearish' ? close[i] <= open[i] : true)
                float Dj = array.get(vp_a_D, j)
                float dDj = Dj + nz(volume[i])
                array.set(vp_a_D, j, dDj)
                Dc += 1
                Dc
        for j = 0 to vp_N_BARS - 1 by 1
            float Vj = array.get(vp_a_V, j)
            float Dj = array.get(vp_a_D, j)
            float dVj = Vj + (Dc > 0 ? Dj / Dc : 0.0)
            array.set(vp_a_V, j, dVj)
    vp_Vmax := array.max(vp_a_V)
    vp_VmaxId := array.indexof(vp_a_V, vp_Vmax)
    for j = 0 to vp_N_BARS - 1 by 1
        float Vj = array.get(vp_a_V, j)
        int Aj = math.round(vp_bar_mult * Vj / vp_Vmax)
        array.set(vp_a_W, j, Aj)

///////////////////////////////////////////////////////////////////////////////////////////////////
//// PLOTTING
///////////////////////////////////////////////////////////////////////////////////////////////////
if barstate.isfirst
    vp_first := time
    vp_first
vp_change = ta.change(time)
vp_x_loc = timenow + math.round(vp_change * vp_bar_offset)

f_setup_bar(n) =>
    x1 = vp_VmaxId == n and vp_poc_show ? math.max(time[vp_lookback], vp_first) : timenow + math.round(vp_change * (vp_bar_offset - array.get(vp_a_W, n)))
    ys = array.get(vp_a_P, n)
    line.new(x1=x1, y1=ys, x2=vp_x_loc, y2=ys, xloc=xloc.bar_time, extend=extend.none, color=vp_VmaxId == n ? vp_poc_color : vp_bar_color, style=line.style_solid, width=vp_bar_width)

if barstate.islast
    for i = 0 to vp_N_BARS - 1 by 1
        f_setup_bar(i)

///////////////////////////////////////////////////////////////////////////////////////////////////
//// END
///////////////////////////////////////////////////////////////////////////////////////////////////
// Module - Enable Kills and Pivot Points
//-----------------------------------------
// Module - Open Range Breakout BOT by CoM_gUnNeR \ idea FOREX, Coded by Rajandran R (Founder - Marketcalls/Co-Founder - Algomojo)
//-----------------------------------------
//*********************************************************
//*                     Module                            *
//*         Open Range Breakout BOT                       *
//*********************************************************
// Calculations
//--------

// Group 1: ORB Module Options
groupORB = "OR Breakout Operation 1Min - 5Min - 15Min - 30 min"
// Visual separation
plot(na)
// , group=groupORB

showORBChannels = input.bool(false, "Show Channels Open Range Breakout", group=groupORB)
showORBLabels = input.bool(false, "Show Labels Open Range Breakout", group=groupORB)
showORBLabelsWithFilter = input.bool(false, "Show Labels Open Range Breakout W.Filter", group=groupORB)
timeFrame = input.timeframe(title='TIME x', defval='180', group=groupORB)  // choose time period: 60M 120M 4hrs 1 week
lineWidth = input.int(title='Line Width', defval=1, minval=1, maxval=5, group=groupORB)

// TREND FILTER
smaBreakout200 = ta.sma(close, 200)

// High and Low values for 60-minute or 180-minute timeframe charts
high_ORB = request.security(syminfo.tickerid, timeFrame, high)
low_ORB = request.security(syminfo.tickerid, timeFrame, low)

orbHigh_ORB = high_ORB
orbLow_ORB = low_ORB

buy_ORB = ta.crossover(high, orbHigh_ORB)
short_ORB = ta.crossunder(low, orbLow_ORB)

// CONTRARY
buyContinue_ORB = ta.barssince(buy_ORB) < ta.barssince(short_ORB)
shortContinue_ORB = ta.barssince(short_ORB) < ta.barssince(buy_ORB)

var isLong_ORB = false
var isShort_ORB = false

buy_ORB := not isLong_ORB and buy_ORB
short_ORB := not isShort_ORB and short_ORB

if buy_ORB
    isLong_ORB := true
    isShort_ORB := false
    isShort_ORB

if short_ORB
    isLong_ORB := false
    isShort_ORB := true
    isShort_ORB

// CONDITIONS LONG SHORT

// WITH TREND FILTER

LongMas_ORB = buy_ORB and close > smaBreakout200 and open > smaBreakout200
ShortMas_ORB = short_ORB and close < smaBreakout200 and open < smaBreakout200

// WITHOUT TREND FILTER

LongMas_ORB_DIR = buy_ORB
ShortMas_ORB_DIR = short_ORB

// AESTHETIC IMPROVEMENT MADE BY 8Zamania

plotshape(showORBLabelsWithFilter ? LongMas_ORB : na, style=shape.labelup, location=location.belowbar, color=color.rgb(26, 156, 30, 38), title='Buy', text='?? LONG', textcolor=color.new(color.white, 0))
plotshape(showORBLabelsWithFilter ? ShortMas_ORB : na, style=shape.labeldown, location=location.abovebar, color=color.new(#ac1c1c, 40), title='Sell', text='?? SHORT', textcolor=color.new(color.white, 0))

plotshape(showORBLabels ? LongMas_ORB_DIR : na, style=shape.labelup, location=location.belowbar, color=color.new(#16961b, 40), title='Buy', text='?? LONG ', textcolor=color.new(color.white, 0))
plotshape(showORBLabels ? ShortMas_ORB_DIR : na, style=shape.labeldown, location=location.abovebar, color=color.new(#941616, 28), title='Sell', text='?? SHORT ', textcolor=color.new(color.white, 0))

plot(showORBChannels ? orbHigh_ORB : na, color=color.new(color.red, 70), style=plot.style_circles, linewidth=lineWidth)
plot(showORBChannels ? orbLow_ORB : na, color=color.new(color.lime, 70), style=plot.style_circles, linewidth=lineWidth)

// Module - Kill Zones
//-----------------------------------------
//*********************************************************
//*                     Module                            *
//*                 Kill Zones                           *
//*********************************************************
// Calculations
//---------

// Group: Module Options
groupKill = "Module - Kill Zones"
// Visual separation
plot(na)
// , group=groupKill

showKills = input.bool(title='Show kill zones', defval=true, group='Pivot Points', group=groupKill)
prd = input.int(title='Pivot Points', defval=2, minval=1, maxval=50, group='Pivot Points', inline='PRD')
factorAtr = input.float(title='ATR: Factor ', defval=3, minval=1, step=0.1, group='Pivot Points', inline='ATR')
periodoAtr = input.int(title='Period', defval=10, minval=1, group='Pivot Points', inline='ATR')

float ph = na
float pl = na
ph := ta.pivothigh(prd, prd)
pl := ta.pivotlow(prd, prd)

float center = na
center := center[1]
float lastpp = ph ? ph : pl ? pl : na
if lastpp
    if na(center)
        center := lastpp
        center
    else
        center := (center * 2 + lastpp) / 3
        center

Up = center - factorAtr * ta.atr(periodoAtr)
Dn = center + factorAtr * ta.atr(periodoAtr)

float TUp = na
float TDown = na
Trend = 0
TUp := close[1] > TUp[1] ? math.max(Up, TUp[1]) : Up
TDown := close[1] < TDown[1] ? math.min(Dn, TDown[1]) : Dn
Trend := close > TDown[1] ? 1 : close < TUp[1] ? -1 : nz(Trend[1], 1)
Trailingsl = Trend == 1 ? TUp : TDown
linecolor = Trend == 1 and nz(Trend[1]) == 1 ? color.lime : Trend == -1 and nz(Trend[1]) == -1 ? color.red : na
bsignal = Trend == 1 and Trend[1] == -1
ssignal = Trend == -1 and Trend[1] == 1

float resistance = na
float support = na
support := pl ? pl : support[1]
resistance := ph ? ph : resistance[1]

// Module - Information Box
//-----------------------------------------
//*********************************************************
//*                     Module                            *
//*                  INFORMATION                          *
//*********************************************************
// Calculations
//////////////////////////////////////////////////////////////////////////////////////////////////
//// INPUTS
///////////////////////////////////////////////////////////////////////////////////////////////////

// Group: Infobox Module Options
groupinfbox = "INFOBOX - KAKUPAKAT"
// Visual separation
plot(na)
// , group=groupinfbox

i_offsetLabel = input.int(defval=40, title='Label Horizontal Offset', minval=0, maxval=205, group=groupinfbox)

offset = i_offsetLabel * (time - time[1])
splitter = '__________________'
nl = '\n'
title = 'Kakupakat Trading' + nl + ' INFO. BOX' 

string dynamicText = title + nl
var label id = na
label.delete(id)
id := label.new(x=time + offset, y=close, xloc=xloc.bar_time, text=dynamicText)

// LABEL VARIABLES
i_showDOMINANCE = input(false, 'Show DOMINANCE', group=groupinfbox)
i_showMACD = input(true, 'Show MACD', group=groupinfbox)
i_showRSI = input(true, 'Show RSI', group=groupinfbox)
i_showRSIcross = input(true, 'Show Cross RSI', group=groupinfbox)
i_showEstochastic = input(true, 'Show STOCH', group=groupinfbox)
i_showADX = input(true, 'Show ADX', group=groupinfbox)
i_showSQUEEZE = input(true, 'Show SQUEEZE', group=groupinfbox)
i_showKILSS = input(false, 'Show KILLS', group=groupinfbox)
i_showORB= input(true, 'Breakout Alert', group=groupinfbox)

// ROUNDS
f_round(_val, _decimals) =>
    if _decimals == -1
        _val
    else
        _p = math.pow(10, _decimals)
        math.round(math.abs(_val) * _p) / _p * math.sign(_val)

f_strHelp(_prefix, _var, _round) =>
    _res = str.tostring(f_round(_var, _round))
    _prefix + ' ' + _res + nl

// DOMINANCE Section
DOMINANCETitle = splitter + nl + nl + 'Crypto Dominance??' + nl
BTCDClose = request.security('BTC.D', 'M', close)
BTCD = f_strHelp('BTC ? % ›', BTCDClose, 1)
ETHDClose = request.security('ETH.D', 'M', close)
ETHD = f_strHelp('ETH ? % ›', ETHDClose, 1)
DOMINANCESection = i_showDOMINANCE ? DOMINANCETitle + nl + BTCD + ETHD : na

// MACD Section
MACDTitle = splitter + nl
[macd, macdsignal, macdhist] = ta.macd(close, fastlen=12, slowlen=26, siglen=9)
trend3 = macdhist > 0 ? '[ Bullish ?? Alcista ]' : '[ Bearish ?? Bajista ]'
MACDSection = i_showMACD ? MACDTitle + nl + 'MACD Trend ?? :' + nl + nl + trend3 + nl : na

// RSI Section
RSITitle = splitter + nl
rsibase = ta.rsi(close, 14)
Trend1 = rsibase > 80 ? nl + '?? ?? ??' + '[ RSI OVERBUY??' + nl + 'RSI SOBRECOMPRA]' : na 
Trend2 = rsibase < 20 ? nl + '?? ?? ??' + '[ RSI OVERSELL??' + nl + 'RSI SOBREVENTA]' : na 
RSISection = i_showRSI ? RSITitle + nl + f_strHelp('RSI:', rsibase, 1) + Trend1 + Trend2 + nl : na  + nl  

// Stochastic Section
EstochasticTitle = splitter + nl
periodK = 14
periodD = 3
smoothK = 3
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)
Trend1stoch = k > 80 ? nl + nl + '???????? ' + nl  + nl + '[ STOCH OVERBUY ??' + nl + 'STOCH SOBRECOMPRA]' + nl : na + nl 
Trend2stoch = k < 20 ? nl + nl + '???????? ' + nl  + nl + '[ STOCH OVERSELL ??' + nl + 'STOCH SOBREVENTA]' + nl : na + nl 
EstochasticSection = i_showEstochastic ? nl + EstochasticTitle + nl +  f_strHelp('STOCH K:', k, 1) + f_strHelp('STOCH D:', d, 1) + nl + Trend1stoch + Trend2stoch + nl : na + nl 

Trend1stochcrossUp = ta.crossover(k, d) ? '????' + nl + '[Up +]' : na  + nl
Trend2stochcrossDown = ta.crossunder(k, d) ? '????' + nl + '[Down -]' : na + nl
EstochasticSection2 = i_showEstochastic ? EstochasticTitle + nl +'STOCH CROSS K/D:' + Trend1stochcrossUp + Trend2stochcrossDown + nl : na + nl

// CREDITS
TelegramTitle = splitter + nl
url = "https://t.me/kakupakat_trading_oficial"  
string linkText = "https://t.me/kakupakat_trading_oficial"
displayText = "<a href='" + url + "'>" + linkText + "</a>"
TelegramSection = TelegramTitle + nl + 'TELEGRAM' + nl + url + nl


// Starts ADX
//-----------------------------------------
// Inputs ADX
DMIlength = 14
ATR = ta.atr(14)

// +DM and -DM
upMove = high - high[1]
dnMove = low[1] - low
plusDM = upMove > dnMove and upMove > 0 ? upMove : 0
minusDM = dnMove > upMove and dnMove > 0 ? dnMove : 0

// SMMA Wilder; SMMA(x,y) = RMA(x,y) or SMMA(x,y) = EMA(x, (2 * y - 1))
MAcalc(x, y) =>
    ma = ta.rma(x, y)
    ma

// +DI,-DI and ADX
plusDI = 100 * (MAcalc(plusDM, DMIlength) / ATR)
minusDI = 100 * (MAcalc(minusDM, DMIlength) / ATR)
absDX = 100 * math.abs((plusDI - minusDI) / (plusDI + minusDI))

// Add a variable to store the previous value of ADX
var float prevADX = na
var float prevADX2 = na
var float prevADX3 = na
var float prevADX4 = na

// Calculate ADX as in the original code
ADX = MAcalc(absDX, DMIlength)
ADXTitle = splitter + nl
Trend1ADX = ADX > 25 ? '??'  + '[ STRONG TREND' + nl + 'STRONG TREND ]' : na  + nl 
Trend2ADX = ADX < 20 ? '??'  + '[ WEAK TREND' + nl + 'WEAK TREND ]' : na + nl
ADXSection = i_showADX ? ADXTitle  + f_strHelp('ADX  Value:', ADX, 1) + Trend1ADX + Trend2ADX + nl : na
ADXTitle2 = splitter + nl
dirADX = plusDI > minusDI ? '[ Bullish ?? Bullish ]' : '[ Bearish ?? Bearish ]'
ADXSection2 = i_showADX ? ADXTitle2 + 'ADX Direction:' + nl + dirADX + nl : na
cruceLongADX = ta.crossover(plusDI, minusDI) ? '????' + nl  + '[ CROSS + ' + 'ADX + ]' : na
cruceShortADX = ta.crossunder(plusDI, minusDI) ? '????' + nl  + '[ CROSS - ' + 'ADX - ]' : na
ADXSection3 = i_showADX ? ADXTitle2 + 'ADX Cross:' + cruceLongADX + cruceShortADX + nl : na
// Ends ADX

// Starts Breakout Alert
ORBTitle2 = splitter + nl
ORBAlertUp = LongMas_ORB_DIR ? '??' + nl  + '[ Up]' : na
ORBAlertDn = ShortMas_ORB_DIR ? '??' + nl  + '[ Down]' : na
ORBSection = i_showORB ? ORBTitle2 + 'BREAKOUT ALERT:' + ORBAlertUp + ORBAlertDn + nl : na
// Ends Breakout Alert

// Starts Squeeze Momentum
lengthSqueeze = 20
multSqueeze = 2
lengthKCSqueeze = 20
multKCSqueeze = 1.5
strengthSqueeze = 0.0018
useTrueRangeSqueeze = input.bool(true, title="Use TrueRange (KC)")

// Calculate BB
sourceSqueeze = close
basisSqueeze = ta.sma(sourceSqueeze, lengthSqueeze)
devSqueeze = multKCSqueeze * ta.stdev(sourceSqueeze, lengthSqueeze)
upperBBSqueeze = basisSqueeze + devSqueeze
lowerBBSqueeze = basisSqueeze - devSqueeze

// Calculate KC
maSqueeze = ta.sma(sourceSqueeze, lengthKCSqueeze)
rangeValSqueeze = useTrueRangeSqueeze ? ta.tr : (high - low)
rangemaSqueeze = ta.sma(rangeValSqueeze, lengthKCSqueeze)
upperKCSqueeze = maSqueeze + rangemaSqueeze * multKCSqueeze
lowerKCSqueeze = maSqueeze - rangemaSqueeze * multKCSqueeze

sqzOnSqueeze  = (lowerBBSqueeze > lowerKCSqueeze) and (upperBBSqueeze < upperKCSqueeze)
sqzOffSqueeze = (lowerBBSqueeze < lowerKCSqueeze) and (upperBBSqueeze > upperKCSqueeze)
noSqzSqueeze  = (sqzOnSqueeze == false) and (sqzOffSqueeze == false)
highestSqueeze = ta.highest(high, lengthKCSqueeze)
lowestSqueeze = ta.lowest(low, lengthKCSqueeze)
lastsmaSqueeze = ta.sma(close,lengthKCSqueeze)
valin = ta.linreg(sourceSqueeze  -  ta.sma((highestSqueeze + lowestSqueeze) / 2, lengthKCSqueeze), lengthKCSqueeze,0)

// SqueezeSection
SqueezeTitle = splitter + nl
SqueezeEndLong = valin < (strengthSqueeze*-1) and valin > nz(valin[1]) ? '????' + nl + '[ Direction End' + nl + 'Direction End ]' : na  
SqueezeEndShort = valin > strengthSqueeze and valin < nz(valin[1])  ? '????' + nl + '[ Direction End' + nl + 'Direction End ]' : na 
SqueezeSection = i_showSQUEEZE ? SqueezeTitle + nl + 'Direction Change Squeeze:' + SqueezeEndLong + SqueezeEndShort   + nl: na

SqueezeCrossUp = ta.crossover(valin, 0)  ?  '??' +'[ 0  UP  ]' : na  
SqueezeCrossDn = ta.crossunder(valin,0)  ?  '??' + '[ 0  DOWN ]' : na 
SqueezeSection2 = i_showSQUEEZE ? SqueezeTitle  + nl + 'CROSS ZERO SQUEEZE:' + nl + SqueezeCrossUp + SqueezeCrossDn  + nl : na
// Ends Squeeze Momentum

// Starts RSI Golden Cross
groupinfboxRsi = "INFOBOX GOLDEN CROSS mRSI"
// Visual separation
plot(na)
// , group=groupinfboxRsi

ma(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "Bollinger Bands" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)

rsiLengthInput = 14
rsiSourceInput = input.source(close)

maTypeInput = input.string("SMA", title="mRSI", group="MA Settings", group=groupinfboxRsi)
maLengthInput = 14
bbMultInput = 2.0

uprsi = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
downrsi = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = downrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / downrsi))
rsiMA = ma(rsi, maLengthInput, maTypeInput)
isBB = maTypeInput == "Bollinger Bands"

// Add a variable to store the previous value of RSI
var float prevRSI = na
var float prevRSI2 = na
var float prevRSI3 = na
var float prevRSI4 = na
// Add a variable to store the previous value of rsiMA
var float prevrsiMA = na
var float prevrsiMA2 = na
var float prevrsiMA3 = na
var float prevrsiMA4 = na

// Store the previous value of RSI
prevRSI := nz(prevRSI[1], rsi[1])
prevRSI2 := nz(prevRSI[2], rsi[2])
prevRSI3 := nz(prevRSI[3], rsi[3])
prevRSI4 := nz(prevRSI[4], rsi[4])

// Store the previous value of rsiMA
prevrsiMA := nz(prevrsiMA[1], rsiMA[1])
prevrsiMA2 := nz(prevrsiMA[2], rsiMA[2])
prevrsiMA3 := nz(prevrsiMA[3], rsiMA[3])
prevrsiMA4 := nz(prevrsiMA[4], rsiMA[4])

RSIcrossTitle = splitter + nl
goldenrsiUp = ta.crossover(rsi, rsiMA) and rsiMA < prevrsiMA and rsiMA < prevrsiMA2  ? '????' + nl + '[ Up + ' + nl + 'Up + ]' : na  + nl
goldenrsiDn = ta.crossunder(rsi, rsiMA)  and rsiMA > prevrsiMA and rsiMA > prevrsiMA2 ? '????' + nl + '[ Down - ' + nl + 'Down - ]' : na + nl
RSIcrossSection = i_showRSIcross ? RSIcrossTitle +'mRSI GOLD CROSS:' + goldenrsiUp + goldenrsiDn : na + nl
mRSItrend = rsi > rsiMA ? '[ Bullish ?? Bullish ]' : '[ Bearish ?? Bearish ]'
RSIcrossSectionTrend = i_showRSIcross ? RSIcrossTitle + nl +  'mRSI Trend:' + nl + nl + mRSItrend + nl : na
// Ends RSI Golden Cross
//KILLS START
//-----------------------------------------
KILLScrossTitle = splitter + nl
KILLSUp = (bsignal and Trailingsl)  ?  '??' + nl + '[ Longs ' + nl + 'Longs ]' : na  
KILLSDn = (ssignal and Trailingsl)  ?  '??' + nl + '[ Shorts ' + nl + 'Shorts ]' : na 
KILLSSection = i_showKILSS ? KILLScrossTitle + nl + 'KILL Zone: ??' + KILLSUp + KILLSDn + nl : na
//KILLS END

// STYLE AND INFOBOX ALERTS
//-----------------------------------------

// STYLE
label.set_textalign(id, text.align_left)
label.set_color(id, color=color.rgb(0, 0, 50, 50))
label.set_textcolor(id, textcolor=color.new(color.orange, 0))
label.set_style(id, label.style_label_left)

// DynamicText
dynamicText := dynamicText + DOMINANCESection + KILLSSection + MACDSection + ORBSection + ADXSection2 + ADXSection + ADXSection3 + SqueezeSection + SqueezeSection2 + RSISection + RSIcrossSection + RSIcrossSectionTrend + EstochasticSection + EstochasticSection2 + TelegramSection
label.set_text(id, text=dynamicText)

if Trend1 == nl + '???? ???? ??' + nl + nl + '[ RSI OVERBUY! ??' + nl + '¡¡RSI OVERBOUGHT!]' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.teal)

if Trend2 == nl + '???? ???? ??' + nl + nl + '[ RSI OVERSELL! ??' + nl + '¡¡RSI OVERSOLD!]' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.maroon)

if Trend1stoch == nl + '???? ???? ??' + nl + nl + '[ STOCH OVERBUY! ??' + nl + '¡¡STOCH OVERBOUGHT!]' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.teal)

if Trend2stoch == nl + '???? ???? ??' + nl + nl + '[ STOCH OVERSELL! ??' + nl + '¡¡STOCH OVERSOLD!]' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.maroon)

if Trend1ADX == nl + '???? ???? ??' + nl + nl + '[ STRONG ADX! ??' + nl + 'STRONG ADX!]' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.teal)

if Trend2ADX == nl + '???? ???? ??' + nl + nl + '[ WEAK ADX! ??' + nl + 'WEAK ADX!]' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.maroon)

if cruceLongADX == nl + '???????? ???? ??' + nl + nl + '[ CROSS ADX! ??' + nl + 'CROSS ADX!]' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.teal)

if cruceShortADX == nl + '???????? ???? ?? ' + nl + nl + '[ CROSS ADX! ??' + nl + 'CROSS ADX!]' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.maroon)

if SqueezeEndLong == nl + '???????? ???? ??' + nl + nl + '[ End Trend Squeeze! ??????' + nl + 'End Trend Squeeze!]' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.teal)

if SqueezeEndShort == nl + '???????? ???? ?? ' + nl + nl + '[ End Trend Squeeze! ??????' + nl + 'End Trend Squeeze!]' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.maroon)

if goldenrsiUp == nl + '???????? ???? ??' + nl + nl + '[ mRSI GOLD CROSS + ??' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.teal)

if goldenrsiDn == nl + '???????? ???? ?? ' + nl + nl + '[ mRSI GOLD CROSS - ??' + nl 
    label.set_textcolor(id, textcolor=color.white)
    label.set_color(id, color.maroon)

//----------//
// END
// Module - ALERTS
//-----------------------------------------
//*********************************************************
//*                      Module                           *
//*                      ALERTS                           *
//*********************************************************
// Original idea calculations by CoMgUnNeR
//--------

// ALL TOGETHER

// Group: INFOBOX Module Options
groupALERT = "ALERTS"
// Visual separation
plot(na)
// , group=groupALERT
// Getting data from other timeframes
temporalidad1 = input.string("60", "Timeframe 1", options=["60", "240"], group=groupALERT)
temporalidad2 = input.string("240", "Timeframe 2", options=["60", "240"], group=groupALERT)
temporalidad3 = input.string("1D", "Timeframe 3", options=["60", "240", "1D"], group=groupALERT)

LongMaster1H = request.security(syminfo.tickerid, temporalidad1, buySignal)
LongMaster4H = request.security(syminfo.tickerid, temporalidad2, buySignal)
LongMaster24H = request.security(syminfo.tickerid, temporalidad3, buySignal)
ShortMaster1H = request.security(syminfo.tickerid, temporalidad1, sellSignal)
ShortMaster4H = request.security(syminfo.tickerid, temporalidad2, sellSignal)
ShortMaster24H = request.security(syminfo.tickerid, temporalidad3, sellSignal)
changeCond1H = request.security(syminfo.tickerid, temporalidad1, sellSignal)
changeCond4H = request.security(syminfo.tickerid, temporalidad2, sellSignal)
changeCond24H = request.security(syminfo.tickerid, temporalidad3, sellSignal)

// Conditions for the alert
condicionLong = LongMaster1H or LongMaster24H
condicionLong2 = LongMaster4H or LongMaster24H
condicionShort = ShortMaster1H or ShortMaster4H
condicionShort2 = ShortMaster4H or ShortMaster24H
condicionCambioDir = changeCond1H or changeCond4H
condicionCambioDir2 = changeCond4H or changeCond24H

// Creating the alerts
alertcondition(buySignal and sellSignal or condicionLong or condicionShort, title="Alert: 1H and 4H BUY/SELL", message="Signal detected in {{ticker}} on timeframes {{interval}}, 1H and 4H")
alertcondition(buySignal and sellSignal or condicionLong2 or condicionShort2, title="Alert: 1D and 4H BUY/SELL", message="Signal detected in {{ticker}} on timeframes {{interval}}, 1D and 4H")
alertcondition(buySignal or condicionCambioDir, title="DIR CHG: 1H and 4H", message="Signal detected in {{ticker}} on timeframes {{interval}}, 1H and 4H")
alertcondition(buySignal or condicionCambioDir2, title="DIR CHG: 4H and 1D", message="Signal detected in {{ticker}} on timeframes {{interval}}, 1H and 4H")
